package com.ssy.lingxi.platform.template.service.controller.web;

import com.ssy.lingxi.common.constant.tree.Node;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.template.service.model.dto.common.TemplateIdDTO;
import com.ssy.lingxi.platform.template.service.model.vo.adorn.CategoryVO;
import com.ssy.lingxi.platform.template.service.model.vo.web.CategoryTreeVO;
import com.ssy.lingxi.platform.template.service.service.web.CategoryWebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu web - 平台品类
 * @author fhj
 * @version 2.0.0
 * @date 2020/12/15
 */
@Api(tags = "web - 平台品类")
@RestController
@RequestMapping("/template/web/categoryWeb")
public class CategoryWebController extends BaseController {

    @Resource
    private CategoryWebService categoryWebService;

    @ApiOperation(value = "获取平台首页平台品类树")
    @GetMapping("/findPlatformCategoryTree")
    public Wrapper<List<Node>> findPlatformCategoryTree() {
        return categoryWebService.findPlatformCategoryTree(getHeadersShopId());
    }

    @ApiOperation(value = "获取企业商城首页平台品类树")
    @GetMapping("/findEnterpriseCategoryTree")
    public Wrapper<List<CategoryTreeVO>> findEnterpriseCategoryTree(TemplateIdDTO dto) {
        return categoryWebService.findEnterpriseCategoryTree(dto, getHeadersShopId());
    }

    @ApiOperation(value = "获取企业直采平台品类树")
    @GetMapping("/findPurchaseCategoryTree")
    public Wrapper<List<Node>> findPurchaseCategoryTree() {
        return categoryWebService.findPurchaseCategoryTree();
    }

    @ApiOperation(value = "获取所有一级平台品类")
    @GetMapping("/findAllFirstCategory")
    public Wrapper<List<CategoryVO>> findAllFirstCategory(@Param("templateId") Long templateId) {
        return categoryWebService.findAllFirstCategory(getHeadersShopId(),templateId);
    }
}
